# 字符串作业

"""
1. 将字符串 "abcd" 转成大写
2. 计算字符串 "cd" 在 字符串 "abcd"中出现的位置
3. 字符串 "a,b,c,d" ，请用逗号分割字符串，分割后的结果是什么类型的？
4. "{name}喜欢{fruit}".format(name="李雷") 执行会出错，请修改代码让其正确执行
5. string = "Python is good", 请将字符串里的Python替换成 python,并输出替换后的结果
6. 有一个字符串 string =  "python修炼第一期.html"，请写程序从这个字符串里获得.html前面的部分，要用尽可能多的方式来做这个事情
7. 如何获取字符串的长度？
8. "this is a book",请将字符串里的book替换成apple
9. "this is a book", 请用程序判断该字符串是否以this开头
10. "this is a book", 请用程序判断该字符串是否以apple结尾
11. "This IS a book"， 请将字符串里的大写字符转成小写字符
12. "This IS a book"， 请将字符串里的小写字符，转成大写字符
13. "this is a book\n"， 字符串的末尾有一个回车符，请将其删除

string = "Python is good"
1. string[1:20]                        # ython is good
2. string[20]                          # IndexError: string index out of range
3. string[3:-4]                        # hon is
4. string[-10:-3]                      # on is g
5. string.lower()                      # python is good
6. string.replace("o", "0")            # pyth0n is g00d
7. string.startswith('python')         # False
8. string.split()                      # ['python','is','good']
9. len(string)                         # 14
10. string[30]                         # IndexError: string index out of range
11. string.replace(" ", '')            # Pythonisgood


"""
print('1========================')
upper = "abcd".upper()
print(upper)

print('2========================')
find = 'abcd'.find('cd')
print(find)

print('3========================')
split = "a,b,c,d".split(sep=',')
print(type(split))
print(split)

print('4========================')
name = '李雷'
fruit = 'apple'
print("{}喜欢{}".format(name, fruit))

print('5========================')
string = "Python is good"
replace = string.replace("P", "p")
print(replace)

print('6========================')
string1 = "python修炼第一期.html"
string1_find = string1.find('.html')
print(string1_find)
result = string1[:string1_find:]
print(result)

string1_split = string1.split(sep='.html')
print(string1_split)
print(string1_split[0])

print('7========================')
len = len(string)
print(len)

print('8========================')
book_replace = "this is a book".replace('book', 'apple')
print(book_replace)

print('9========================')
startswith = "this is a book".startswith('this')
print(startswith)

print('10========================')
endswith = "this is a book".endswith('apple')
print(endswith)

print('11========================')
lower = "This IS a book".lower()
print(lower)

print('12========================')
book_upper = "This IS a book".upper()
print(book_upper)

print('13========================')
strip = "this is a book\n".strip()
print(strip)

print('---========================')





